import * as ts from 'typescript';
import * as tstl from 'typescript-to-lua';
import * as lua from 'typescript-to-lua/dist/LuaAST';

const class_rule = {
    visitors: {
        [ts.SyntaxKind.ClassDeclaration]: (node: ts.ClassDeclaration, context: tstl.TransformationContext) => {
            // 收集私有成员
            const privateMembers = node.members.filter(member =>
                (ts.isPropertyDeclaration(member) || ts.isMethodDeclaration(member)) &&
                member.modifiers?.some(m => m.kind === ts.SyntaxKind.PrivateKeyword)
            );
            // 生成局部变量声明
            const localVariables = privateMembers.map(member => {
                const name = member.name?.getText() as string;
                const initializer = ts.isPropertyDeclaration(member)
                    ? member.initializer
                    : undefined;
                return lua.createVariableDeclarationStatement(
                    lua.createIdentifier(name),
                    initializer ? context.transformExpression(initializer) : lua.createNilLiteral()
                );
            });

            
        }
    }
};



module.exports = class_rule;